﻿using Asp.Versioning;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp;
using Volo.Abp.Application.Dtos;

namespace Himp.TaskScheduling.V1
{
    /// <summary>
    /// 
    /// </summary>
    [Area(TaskSchedulingRemoteServiceConsts.ModuleName)]
    [RemoteService(Name = TaskSchedulingRemoteServiceConsts.RemoteServiceName)]
    [Route("api/taskScheduling/samplePreparationTask")]
    [ApiVersion("1.0")]
    [ApiController]
    [ControllerName("samplePreparationTask")]
    public class SamplePreparationTaskController : TaskSchedulingController, ISamplePreparationTaskService
    {
        private ISamplePreparationTaskService _samplePreparationTaskService;

        public SamplePreparationTaskController(ISamplePreparationTaskService samplePreparationTaskService)
        {
            _samplePreparationTaskService = samplePreparationTaskService;
        }

        [HttpGet]
        public Task<PagedResultDto<SamplePreparationTaskDto>> GetListAsync([FromQuery]SamplePreparationTaskInput input)
        {
            return _samplePreparationTaskService.GetListAsync(input);
        }

        [HttpGet]
        [Route("{id}/plan")]
        public Task<List<SamplePreparationPlanDto>> GetPlanListAsync([FromRoute] string id)
        {
            return _samplePreparationTaskService.GetPlanListAsync(id);
        }

        /// <summary>
        /// 下发制样任务
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        public Task<SamplePreparationTaskDto> PostAsync([FromBody]SamplePreparationTaskCreateOrUpdateDto input)
        {
            return _samplePreparationTaskService.PostAsync(input);
        }

        /// <summary>
        /// 重新下发制样任务
        /// </summary>
        /// <param name="id"></param>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPut]
        [Route("{id}")]
        public Task<SamplePreparationTaskDto> PutAsync([FromRoute]string id, [FromBody] SamplePreparationTaskCreateOrUpdateDto input)
        {
            return _samplePreparationTaskService.PutAsync(id, input);
        }
    }
}
